import { ref, onMounted } from "vue";
import axios from "axios";

export default function useShowCat() {
  //获取一张狗的图片:保存的数据
  const catUrl = ref("");
  const loading = ref(true);
  //获取一张狗的图片:发送请求
  const getCatUrl = async () => {

    const result = await axios.get("  https://api.thecatapi.com/v1/images/search");

    loading.value = false;
    catUrl.value = result.data.message;
  };

  //获取一张狗的图片:生命周期函数
  onMounted(() => {
    getCatUrl();
  });

  return { catUrl, loading };
}
